package com.zhuhao.thinking.in.java;

import java.util.Arrays;

/**
 * 可变参测试
 * @Author haozhu7
 * @Date 2023/9/17 21:53
 **/
public class VarargsDemo {

    public static void main(String[] args) {
        //优先调用无参的函数，只有一个可变参函数时调用调用可变惨
        f();
        f(1);
        f(1, 2D, "dd", new VarargsDemo());

        d(1);
        d(1, "a", "b", "c");
    }

    static void f(Object... args) {
        System.out.println(Arrays.toString(args));
    }

    static void h(Character... args) {
        System.out.println(Arrays.toString(args));
    }

    static void f() {
        System.out.println("f()");
    }

    //可变参必须是函数中的最后一个参数
    static void d(int i, String... strArras) {
        System.out.println("i = " + i);
        System.out.println(Arrays.toString(strArras));

    }
}
